#
#	File:		CheckInAll
#
#	Contains:	Script which checks in all files in current
#				project.
#
#   Written by: Bruce Horn, Steve Capps, Larry Kenyon,
#               John Meier, scott douglass, Darin Adler,
#               Paul Mercer, Bryan Stearns, Dave Owens
#
#	Copyright:	© 1988 by Apple Computer, Inc., all rights reserved.
#
#	Change History:
#
#		2/17/89		sad		use ProjectInfo -s; redirect to {somewhere}
#		11/17/88	sad		fix CanÕt parse logic
#		11/4/88		sad		fix so actually works, current project only
#		11/4/88		sad		cloned from OpenCheckedOut
#
#	To Do:
#		CanÕt handle file names with spaces.
#

Set Exit 0
Set CaseSensitive 0
# the following helps to debug until MPW sends echos to Dev:Console instead of Dev:StdErr
If {Echo} == 1
	Set somewhere "·· '{Worksheet}¶'"
Else
	Set somewhere '· Dev:Null'
End
Begin

	# first get all the check-out directories for the current project
	
	Confirm "Do you want to check in all modifiable files in the project Ò`Project -q`Ó?"
	Exit {Status} If {Status} != 0

	Set CheckOutDirs "`CheckOutDir -r; Set CheckOutDirStatus {Status} ; Echo ""`"
	Exit {CheckOutDirStatus} If {CheckOutDirStatus} != 0

	Loop
		Break If "{CheckOutDirs}" !~ / *CheckOutDir +-project ¶'Ç0,1È([Â:]+º)¨1¶'Ç0,1È ¶'Ç0,1È([Âº]*:)¨2¶'Ç0,1È (Å)¨3/
		Set Project "{¨1}"
		Set CheckOutDir "{¨2}"
		Set CheckOutDirs "{¨3}"

		# now for each directory, get all modified files in the project

		Set Info "`ProjectInfo -s -a "{User}" -m -project "{Project}"; Set ProjectInfoStatus {Status}`"
		# *** check status here

		Set FirstNotOpened ""
		Set OthersNotOpened ""
#		If "{Info}" =~ /[Â,]+º( Ç0,1ÈÅ)¨1/
#			Set Info "{¨1}"
#		End
		Loop
			Break If "{Info}" !~ /[Â+]*    ([Â,]+)¨1,[0-9.a-z]+¶+ (Å)¨2/
			Set File "{¨1}"
			Set Info "{¨2}"
			If "`Exists "{CheckOutDir}{File}"`" == ""
				If "{FirstNotOpened}" == ""
					Set FirstNotOpened "Ò{File}Ó"
				Else
					Set OthersNotOpened "{OthersNotOpened}, Ò{File}Ó"
				End
			Else
				CheckIn "{CheckOutDir}{File}" ·· "{Worksheet}"
			End
		End
#		If "{Info}" != ""
#			Echo "### CheckInAll - CouldnÕt parse: " "{Info}" ··  "{Worksheet}"
#			Exit 1
#		End
		If "{FirstNotOpened}" != ""
			If "{OthersNotOpened}" == ""
				Alert "{FirstNotOpened} is checked out from Ò`Project -q`Ó but is not in the Ò{CheckOutDir}Ó directory."
			Else
				Alert "The following files are checked out from Ò`Project -q`Ó but are not in the Ò{CheckOutDir}Ó directory: {FirstNotOpened}{OthersNotOpened}."
			End
		End
	End
	If "{CheckOutDirs}" != ""
		Echo "### CheckInAll - CouldnÕt parse: " "{CheckOutDirs}" ··  "{Worksheet}"
		Exit 1
	End

End {somewhere}
